<template>
  <div>
    <nut-input
      type="text"
      class="field-input"
      :input-style="Input"
      :border="false"
      :border-bottom="false"
      v-model="text"
      :placeholder="'请输入' + navbarTitle"
    >
    </nut-input>

    <div mt-40rpx class="save">
      <nut-button block type="primary" @click="save">保存</nut-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { InputStyle } from '@/constants/injection-key'
import { onLoad } from '@dcloudio/uni-app'

const Input = {
  ...InputStyle,
  background: '#fff',
  padding: '12rpx 32rpx'
}
const navbarTitle = ref<string>('')
const text = ref<string>('')
const type = ref<string>('')

function save() {
  uni.$emit('save', { type: type.value, value: text.value })
  uni.navigateBack()
}
onLoad((options: any) => {
  navbarTitle.value = options.title
  text.value = options.value
  type.value = options.type
  uni.setNavigationBarTitle({
    title: options.title
  })
})
</script>

<style scoped lang="scss">
.save {
  width: 80%;
  margin: 40rpx auto 0 auto;
}
</style>
